package com.intelligent.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.intelligent.pojo.SupplierReconciliation;
import com.intelligent.service.SupplierReconciliationService;
import com.intelligent.utils.Result;
import com.intelligent.vo.SupplierReconciliationPage;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@RestController
@RequestMapping("/supplier/reconciliation")
public class SupplierReconciliationController {

    @Autowired
    private SupplierReconciliationService supplierReconciliationService;

    //分页查询
    @PostMapping("/page")
    public Result<Page<SupplierReconciliation>> page(@RequestBody SupplierReconciliationPage req) {
        Page<SupplierReconciliation> page = supplierReconciliationService.pageReconciliation(req);
        return Result.success(page);
    }

    //新建功能
    @PostMapping
    public Result<Boolean> create(@RequestBody SupplierReconciliation reconciliation) {
        boolean success = supplierReconciliationService.createReconciliation(reconciliation);
        return Result.success(success);
    }


    //查看详情
    @GetMapping("/{id}")
    public Result<SupplierReconciliation> detail(@PathVariable Long id) {
        SupplierReconciliation reconciliation = supplierReconciliationService.getReconciliationDetail(id);
        return Result.success(reconciliation);
    }
}
